home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / protocol / standard / misc / graphics / atarist / text0000.txt < prev   
Encoding:
Text File  |  1993-07-14  |  29.6 KB  |  761 lines

  1.  
  2. This is a document describing mostly Atari ST picture formats. Obscure,
  3. yes, but might come in handy for someone someday. It is copyrighted but
  4. I think the distribution terms fit your standards. Would go in
  5. Standards/Graphics/Formats/Atari_ST.doc or something.
  6.  
  7. Are you interested in people passing things like this to you? There's
  8. a lot of obscure stuff out there...
  9.  
  10. -- greg
  11.  
  12. orgininal: atari.archive.umich.edu:~/atari/graphics/picfmt.doc
  13.  
  14.                            ST Picture Formats
  15.                            ------------------
  16.                                Edited by:
  17.  
  18.                               David Baggett
  19.                          5640 Vantage Point Road
  20.                          Columbia, MD  21044 USA
  21.                              (301)  596-4779    
  22.                           (usenet: dmb@TIS.COM)
  23.  
  24.                    (Please report errors or additions.)
  25.  
  26.         Copyright (C) 1988, 1989, 1990, 1991 by David M. Baggett
  27.  
  28.  
  29.     Non-profit redistribution of this document is permitted, provided
  30.     the document is not modified in any way.
  31.  
  32.     Reproduction of this document in whole or in part for  commercial
  33.     purposes is expressly forbidden without the prior written consent
  34.     of David M. Baggett.
  35.  
  36.     The  information  presented here is not guaranteed to be correct.
  37.     The editor and contributors will in no event be liable for direct,
  38.     indirect, incidental, or consequential damages resulting from the 
  39.     use of the information in this document.
  40.  
  41.     This document is the product of many hours of volunteer work by a
  42.     large number of people. Please respect this -- do not violate the
  43.     distribution policy.
  44.  
  45.  
  46.                               CONTRIBUTORS
  47.   
  48.     Steve Belczyk  Phil Blanchfield  Jason Blochowiak  John Brochu**
  49.        David Brooks  Daniel Deimert  Neil Forsyth   Stefan Hoehn  
  50.         Gerfried Klein   Ken MacLeod  Jim McCabe  Darek Mihocka   
  51.          David Mumper   George Nassas   George Seto  Joe Smith  
  52.               Greg Wageman   Roland Waldi*  Gerry Wheeler
  53.  
  54.  
  55.                                 Contents 
  56.                                 --------
  57.  
  58.         NEOchrome                               *.NEO
  59.         NEOchrome Animation                     *.ANI
  60.         DEGAS                                   *.PI?   ? = 1, 2, 3
  61.         DEGAS Elite                             *.PI?   ? = 1, 2, 3
  62.         DEGAS Elite (Compressed)                *.PC?   ? = 1, 2, 3
  63.         Tiny                                    *.TN?   ? = 1, 2, 3, Y
  64.         Spectrum 512                            *.SPU
  65.         Spectrum 512 (Compressed)               *.SPC
  66.         Art Director                            *.ART
  67.         C.O.L.R. Object Editor Mural            *.MUR
  68.         Doodle                                  *.DOO
  69.         Animatic Film                           *.FLM
  70.         GEM Bit Image                           *.IMG
  71.         STAD                                    *.PAC
  72.         Imagic Film/Picture                     *.IC?   ? = 1, 2, 3
  73.         IFF                                     *.IFF
  74.         MacPaint                                *.MAC
  75.         PackBits Compression Algorithm
  76.  
  77.  
  78.                         Introductory Information
  79.                         ------------------------
  80. word    = 2 bytes
  81. long    = 4 bytes
  82. palette = Hardware color palette, stored as 16 words.  First word is
  83.           color register zero (background), last word is color register
  84.           15.  Each word has the form:
  85.  
  86.           Bit:  (MSB) 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 (LSB)
  87.                       -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  88.                        0  0  0  0  0 R2 R1 R0  0 G2 G1 G0  0 B2 B1 B0
  89.  
  90.           R2 = MSB of red intensity
  91.           R0 = LSB of red intensity
  92.  
  93.           G2 = MSB of green intensity
  94.           G0 = LSB of green intensity
  95.  
  96.           B2 = MSB of blue intensity
  97.           B0 = LSB of blue intensity
  98.  
  99.           Intensity ranges from 0 (color not present) to 7 (highest
  100.           intensity).
  101.  
  102.           Example: { red = 7, green = 3, blue = 5 } -> 0735 (hex)
  103.  
  104.           Caveat:  It is wise to mask off the upper four bits of each
  105.                    palette entry, since a few programs store special
  106.                    information there (most notably Art Studio).
  107.  
  108.  
  109.                              The Formats
  110.                              -----------
  111.  
  112. <NEOchrome>     *.NEO
  113.  
  114. 1 word          flag byte [always 0]
  115. 1 word          resolution [0 = low res, 1 = medium res, 2 = high res]
  116. 16 words        palette
  117. 12 bytes        filename [usually "        .   "]
  118. 1 word          color animation limits.  High bit (bit 15) set if color
  119.                 animation data is valid.  Low byte contains color animation
  120.                 limits (4 most significant bits are left/lower limit,
  121.                 4 least significant bits are right/upper limit).
  122. 1 word          color animation speed and direction.  High bit (bit 15) set
  123.                 if animation is on.  Low order byte is # vblanks per step.
  124.                 If negative, scroll is left (decreasing).  Number of vblanks
  125.                 between cycles is |x| - 1
  126. 1 word          # of color steps (as defined in previous word) to display
  127.                 picture before going to the next.  (For use in slide shows)
  128. 1 word          image X offset [unused, always 0]
  129. 1 word          image Y offset [unused, always 0]
  130. 1 word          image width [unused, always 320]
  131. 1 word          image height [unused, always 200]
  132. 33 words        reserved for future expansion
  133. 16000 words     picture data (screen memory)
  134. -----------
  135. 32128 bytes     total
  136.  
  137.  
  138. <NEOchrome Animation>        *.ANI
  139.  
  140. NOTE:      To get this feature on versions 0.9 and later select the Grabber
  141.         icon and click both mouse buttons in the eye of the second R in the
  142.         word GRABBER.
  143.            Interestingly enough, some versions of NEO only require you
  144.         to press the right button, not both.  Hmmm...
  145.  
  146. 1 long          magic number BABEEBEA (hex) (seems to be ignored)
  147. 1 word          width of image in bytes (always divisible by 8)
  148. 1 word          height of image in scan lines
  149. 1 word          size of image in bytes + 10 (!)
  150. 1 word          x coordinate of image (must be divisible by 16) - 1
  151. 1 word          y coordinate of image - 1
  152. 1 word          number of frames
  153. 1 word          animation speed (# vblanks to delay between frames)
  154. 1 long          reserved; should be zero
  155. --------
  156. 22 bytes        total for header
  157.  
  158. ? words         image data (words of screen memory) for each frame, in 
  159.                 order
  160.  
  161.  
  162. <DEGAS>         *.PI1 (low resolution)
  163.                 *.PI2 (medium resolution)
  164.                 *.PI3 (high resolution)
  165.  
  166. 1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
  167.                 Other bits may be used in the future; use a simple bit
  168.                 test rather than checking for specific word values.
  169. 16 words        palette
  170. 16000 words     picture data (screen memory)
  171. -----------
  172. 32034 bytes     total
  173.  
  174.  
  175. <DEGAS Elite>   *.PI1 (low resolution)
  176.                 *.PI2 (medium resolution)
  177.                 *.PI3 (high resolution)
  178.  
  179. 1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
  180.                 Other bits may be used in the future; use a simple bit
  181.                 test rather than checking for specific word values.
  182. 16 words        palette
  183. 16000 words     picture data (screen memory)
  184. 4 words         left color animtion limit table (starting color numbers)
  185. 4 words         right color animation limit table (ending color numbers)
  186. 4 words         animation channel direction flag (0 = left, 1 = off, 2 = right)
  187. 4 words         128 - animation channel delay in 1/60's of a second. [0 - 128]
  188.                 (I.e., subtract word from 128 to get 1/60th's of a second.)
  189. -----------
  190. 32066 bytes     total
  191.  
  192.  
  193. <DEGAS Elite (Compressed)>      *.PC1 (low resolution)
  194.                                 *.PC2 (medium resolution)
  195.                                 *.PC3 (high resolution)
  196.  
  197. 1 word          resolution (same as Degas, but high order bit is set;
  198.                 i.e., hex 8000 = low res, hex 8001 = medium res,
  199.                 hex 8002 = high res).  Other bits may be used in the
  200.                 future; use a simple bit test rather than checking
  201.                 for specific word values.
  202. 16 words        palette
  203. < 32000 bytes   control/data bytes
  204. 4 words         left color animation limit table (starting color numbers)
  205. 4 words         right color animation limit table (ending color numbers)
  206. 4 words         animation channel direction flag [0 = left, 1 = off, 2 = right]
  207. 4 words         128 - animation channel delay in 1/60's of a second. [0 - 128]
  208.                 (I.e., subtract word from 128 to get 1/60th's of a second.)
  209. -----------
  210. < 32066 bytes   total
  211.  
  212. Compression Scheme:
  213.  
  214.    PackBits compression is used (see below).  Each scan line is compressed
  215. separately; i.e., all data for a given scan line appears before any data
  216. for the next scan line.  The scan lines are specified from top to bottom
  217. (i.e., 0 is first).  For each scan line, all the data for a given bit plane
  218. appears before any data for the next higher order bit plane.  Note this is
  219. identical to the IFF 'BODY' image data.
  220.    To clarify:  The first data in the file will be the data for the lowest
  221. order bit plane of scan line zero, followed by the data for the next higher
  222. order bit plane of scan line zero, etc., until all bit planes have been
  223. specified for scan line zero.  The next data in the file will be the data
  224. for the lowest order bit plane of scan line one, followed by the data for
  225. the next higher order bit plane of scan line one, etc., until all bit planes
  226. have been specified for all scan lines.
  227.  
  228. Caveats:
  229.  
  230.    DEGAS Elite's picture loading routine places some restrictions on
  231. compressed DEGAS files:
  232.  
  233.         o Elite uses a 40-byte buffer to store data being decompressed.
  234.  
  235.         o Whenever a control command is encountered, bytes are stuffed
  236.         in this buffer.
  237.  
  238.         o The buffer is only emptied when there are EXACTLY 40
  239.         characters in it.
  240.  
  241. The important conclusion here is that
  242.  
  243.         No control command may cause the buffer to have more than 40
  244.         bytes in it.  In other words, all control commands must end on
  245.         or before the 40-byte boundary.
  246.  
  247. Any picture violating the last condition will cause Elite to get a bus
  248. error when the picture is loaded.
  249.  
  250.  
  251. <Tiny>  *.TNY (any resolution)
  252.         *.TN1 (low resolution)
  253.         *.TN2 (medium resolution)
  254.         *.TN3 (high resolution)
  255.  
  256.    Several people have reported sightings of mutated Tiny pictures that
  257. do not follow the standard format, so let's be careful out there.  What
  258. is described here is the format that David Mumper's original
  259. TNYSTUFF.PRG produces.
  260.  
  261. 1 byte          resolution (same as NEO, but +3 indicates rotation
  262.                 information also follows)
  263.  
  264. If resolution > 2 {
  265. 1 byte          left and right color animation limits.  High 4 bits
  266.                 hold left (start) limit; low 4 bits hold right (end)
  267.                 limit
  268. 1 byte          direction and speed of color animation (negative value
  269.                 indicates left, positive indicates right, absolute value
  270.                 is delay in 1/60's of a second.
  271. 1 word          color rotation duration (number of iterations)
  272. }
  273.  
  274. 16 words        palette
  275. 1 word          number of control bytes
  276. 1 word          number of data words
  277. 3-10667 bytes   control bytes
  278. 1-16000 words   data words
  279. -------------
  280. 42-32044 bytes  total
  281.  
  282. Control byte meanings:
  283.  
  284.         For a given control byte, x:
  285.  
  286.         x < 0   Absolute value specifies the number of unique words to
  287.                 take from the data section (from 1 to 127)
  288.         x = 0   1 word is taken from the control section which specifies
  289.                 the number of times to repeat the next data word (from
  290.                 128 to 32767)
  291.         x = 1   1 word is taken from the control section which specifies
  292.                 the number of unique words to be taken from the data
  293.                 section (from 128 - 32767)
  294.         x > 1   Specifies the number of times to repeat the next word
  295.                 taken from the data section (from 2 to 127)
  296.  
  297. Format of expanded data:
  298.  
  299.    The expanded data is not simply screen memory bitmap data; instead, the 
  300. data is divided into four sets of vertical columns.  (This results in
  301. better compression.)  A column consists of one specific word taken
  302. >from each scan line, going from top to bottom.  For example, column 1 
  303. consists of word 1 on scanline 1 followed by word 1 on scanline 2, etc., 
  304. followed by word 1 on scanline 200.
  305.    The columns appear in the following order:
  306.  
  307.    1st set contains columns 1, 5,  9, 13, ..., 69, 73, 77 in order
  308.    2nd set contains columns 2, 6, 10, 14, ..., 70, 74, 78 in order
  309.    3rd set contains columns 3, 7, 11, 15, ..., 71, 75, 79 in order
  310.    4th set contains columns 4, 8, 12, 16, ..., 72, 76, 80 in order
  311.  
  312. Note that Tiny partitions the screen this way regardless of resolution; i.e., 
  313. these aren't bitplanes.  For example, medium resoltion only has two bitplanes, 
  314. but Tiny still divides medium resolution pictures into four parts.
  315.  
  316.  
  317. <Spectrum 512>  *.SPU
  318.  
  319. 80 words        first scan line of picture (unused) -- should be zeroes
  320. 15920 words     picture data (screen memory) for scan lines 1 through 199
  321. 9552 words      3 palettes for each scan line (the top scan line is
  322.                 not included because Spectrum 512 can't display it)
  323. -----------
  324. 51104 bytes     total
  325.  
  326. Note that the Spectrum 512 mode's three palette changes per scan
  327. line allow more colors on the screen than normally possible, but a
  328. tremendous amount of CPU time is required to maintain the image.
  329.  
  330. The Spectrum format specifies a palette of 48 colors for each scan line.
  331. To decode a Spectrum picture, one must be know which of these 48 colors
  332. are in effect for a given horizontal pixel position.
  333.  
  334. Given an x-coordinate (from 0 to 319) and a color index (from 0 to 15),
  335. the following C function will return the proper index into the Spectrum
  336. palette (from 0 to 47):
  337.  
  338. /*
  339.  *  Given an x-coordinate and a color index, returns the corresponding
  340.  *  Spectrum palette index.
  341.  *
  342.  *  by Steve Belczyk; placed in the public domain December, 1990.
  343.  */
  344. int 
  345. FindIndex(x, c)
  346.     int x, c;
  347. {
  348.     int x1;
  349.  
  350.     x1 = 10 * c;
  351.  
  352.     if (1 & c)        /* If c is odd */
  353.         x1 = x1 - 5;
  354.     else            /* If c is even */
  355.         x1 = x1 + 1;
  356.  
  357.     if (x >= x1 && x < x1 + 160) 
  358.         c = c + 16;
  359.     else if (x >= x1 + 160) 
  360.         c = c + 32;
  361.  
  362.     return c;
  363. }
  364.  
  365.  
  366. <Spectrum 512 (Compressed)>        *.SPC
  367.  
  368. 1 word          flag word [$5350 or "SP"]
  369. 1 word          reserved for future use [always 0]
  370. 1 long          length of data bit map
  371. 1 long          length of color bit map
  372. <= 32092 bytes  compressed data bit map
  373. <= 17910 bytes  compressed color bit map
  374. --------------
  375. <= 50014 bytes   total
  376.  
  377. Data compression:
  378.  
  379.    Compression is via a modified run length encoding (RLE) scheme,
  380. similar to DEGAS compressed and Tiny.  The data map is stored as a
  381. sequence of records.  Each record consists of a header byte followed by
  382. one or more data bytes.  The meaning of the header byte is as follows:
  383.  
  384.         For a given header byte, x:
  385.  
  386.            0 <= x <= 127   Use the next x + 1 bytes literally (no repetition)
  387.         -128 <= x <=  -1   Use the next byte -x + 2 times
  388.  
  389. The data appears in the following order:
  390.  
  391.         1. Picture data, bit plane 0, scan lines 1 - 199
  392.         2. Picture data, bit plane 1, scan lines 1 - 199
  393.         3. Picture data, bit plane 2, scan lines 1 - 199
  394.         4. Picture data, bit plane 3, scan lines 1 - 199
  395.  
  396. Decompression of data ends when 31840 data bytes have been used.
  397.  
  398. Color map compression:
  399.  
  400.    Each 16-word palette is compressed separately.  There are three
  401. palettes for each scan line (597 total).  The color map is stored as a
  402. sequence of records.  Each record starts with a 1-word bit vector which
  403. specifies which of the 16 palette entries are included in the data
  404. following the bit vector (1 = included, 0 = not included).  If a palette
  405. entry is not included, it is assumed to be zero (black).  The least
  406. significant bit of the bit vector refers to palette entry zero, while the
  407. most significant bit refers to palette entry 15.  Bit 15 must be zero,
  408. since Spectrum 512 does not use palette entry 15.  Bit 0 should also be
  409. zero, since Spectrum 512 always makes the background color black.
  410.    The words specifying the values for the palette entries indicated in
  411. the bit vector follow the bit vector itself, in order (0 - 15).
  412.  
  413.  
  414. <Art Director>  *.ART (low resolution only)
  415.  
  416. 16000 words     picture data (screen memory)
  417. 16 words        palette
  418. 15 * 16 words   15 more palettes for animation
  419. -------------
  420. 32512 bytes     total
  421.  
  422.  
  423. <C.O.L.R. Object Editor Mural>        *.MUR (low resolution only)
  424.  
  425. 16000 words     picture data (screen memory)
  426.                 (palettes are stored in separate files)
  427. -----------
  428. 32000 bytes     total
  429.  
  430.  
  431. <Doodle>        *.DOO (high resolution only)
  432.  
  433. 16000 words     picture data (screen memory)
  434. -----------
  435. 32000 bytes     total
  436.  
  437.  
  438. <Animatic Film> *.FLM (low resolution only)
  439.  
  440. 1 word          number of frames
  441. 16 words        palette
  442. 1 word          speed (0 - 99; value is 99 - # vblanks to delay between frames)
  443. 1 word          direction (0 = forwards, 1 = backwards)
  444. 1 word          end action (what to do after the last frame)
  445.                 0 = pause, then repeat from beginning
  446.                 1 = immediately repeat from beginning
  447.                 2 = reverse (change direction)
  448. 1 word          width of film in pixels
  449. 1 word          height of film in pixels
  450. 1 word          Animatic version number (major)
  451. 1 word          Animatic version number (minor)
  452. 1 long          magic number 27182818 (hex)
  453. 3 longs         reserved for expansion (should be all zeros)
  454. --------
  455. 32 words        total for header
  456.  
  457. ? words         image data (words of screen memory) for each frame, in order
  458.  
  459.  
  460. <GEM Bit Image> *.IMG
  461.  
  462. 1 word          version number of image file [1]
  463. 1 word          length of header in words [usually 8]
  464. 1 word          number of color planes [1 for monochrome]
  465. 1 word          pattern length in bytes [1-8, usually 2 for screen images]
  466. 1 word          pixel width in microns (1/1000 mm, 25400 microns per inch)
  467. 1 word          pixel height in microns
  468. 1 word          line width in pixels
  469. 1 word          number of lines
  470. -------
  471. ? words         header length defined in 2nd word of header
  472.  
  473. ? bytes         data
  474.  
  475. NOTES:  If the image is a color image (planes > 1), the planes are stored
  476. separately starting with plane 0.  There is, however, no standard way of
  477. storing the color palette.  Some programs may save the palette in separate
  478. files, some may extend the header.  For this reason, you should never
  479. assume the header is 8 words long, always get the header length from the
  480. 2nd word of the header.  Also, the line width in the 7th word is the number
  481. of pixels in a line.  Since the data is encoded in byte-wide packets, the
  482. actual unpacked line width is always a multiple of 8, and may be 1-7 pixels
  483. longer than the length specified in the header.
  484.  
  485. For each byte x in the data section,
  486.  
  487.         x = 0           Pattern/scanline run.
  488.                         Read the next byte, n (unsigned).
  489.  
  490.                         If n > 0 then:
  491.                                 Read a number of bytes equal to the "pattern
  492.                                 length" word in the header.  Repeat this
  493.                                 pattern n times.
  494.  
  495.                         If n = 0 then:
  496.                                 Scanline run.  Data for the next scanline
  497.                                 is to be used multiple times.  Read the
  498.                                 following record:
  499.  
  500.                                 1 byte          flag byte [$FF]
  501.                                 1 byte          number of times to use
  502.                                                 next scanline data
  503.  
  504.                                 The data for the next scanline follows,
  505.                                 compressed normally.
  506.  
  507.         x = 80 (hex)    Uncompressed bit string.  The next byte
  508.                         determines the number of bytes to use
  509.                         literally.  The literal data bytes follow.
  510.  
  511.         otherwise       Solid run.  The value of x determines
  512.                         what to draw.  The high bit specifies whether
  513.                         the pixels are set or cleared.  A 1 indicates
  514.                         a byte-run using $FF, a 0 indicates a byte-run
  515.                         using $00.  The low 7 bits, taken as an unsigned
  516.                         quantity, specify the length of the run in bytes.
  517.  
  518.  
  519. <STAD>          *.PAC (high resolution only)
  520.  
  521. 4 bytes         "pM86" (vertically packed) or "pM85" (horizontally packed)
  522. 1 byte          id byte
  523. 1 byte          pack byte (most frequently occuring byte in bitmap)
  524. 1 byte          "special" byte
  525. -------
  526. 7 bytes         total for header
  527.  
  528. ? bytes         data
  529.  
  530. The data is encoded as follows.  For each byte x in the data section:
  531.  
  532.         x = id byte             Read one more byte, n.  Use pack byte 
  533.                                 n + 1 times.
  534.         x = "special" byte      Read two more bytes, d, and n (in order).
  535.                                 Use byte d n times.
  536.         otherwise               Use byte x literally.
  537.  
  538.  
  539. <Imagic Film/Picture>           *.IC1 (low resolution)
  540.                                 *.IC2 (medium resolution)
  541.                                 *.IC3 (high resolution)
  542.  
  543. 4 bytes         "IMDC"
  544. 1 word          resolution (0 = low res, 1 = medium res, 2 = high res)
  545. 16 words        palette
  546. 1 word          date (GEMDOS format)
  547. 1 word          time (GEMDOS format)
  548. 8 bytes         name of base picture file (for delta compression), or zeroes
  549. 1 word          length of data (?)
  550. 1 long          registration number
  551. 8 bytes         reserved
  552. 1 byte          compressed? (0 = no, 1 = yes)
  553.  
  554. If compressed {
  555. 1 byte          delta-compressed? (-1 = no, > -1 = yes)
  556. 1 byte          ?
  557. 1 byte          escape byte
  558. }
  559. -------
  560. 65 bytes        total for header (68 bytes if compressed)
  561.  
  562. ? bytes         data
  563.  
  564.    Compressed data may be either stand-alone or delta-compressed (relative
  565. to the base picture named in the header).  Delta compression involves
  566. storing only how the picture differs from the base picture (i.e., only
  567. portions of the screen that have changed are stored).  This is used to
  568. to encode animated sequences efficiently.
  569.  
  570. Compressed data, stand-alone:
  571.  
  572. For each byte x in the data section:
  573.  
  574.         x = escape byte         Read one more byte, n.  (n is unsigned).
  575.  
  576.                                 If n >= 2, use the next byte n times.
  577.                                 If n = 1, keep reading bytes until a
  578.                                 byte k not equal to 1 is encountered.
  579.                                 Then read the next byte d.
  580.                                 If the number of 1 bytes encountered is o,
  581.                                 use d (256 * o + k) times.  I.e.,
  582.  
  583.                                 if (n == 1) {
  584.                                         o = 0;
  585.                                         while (n == 1) {
  586.                                                 o++;
  587.                                                 n = next byte;
  588.                                         }
  589.  
  590.                                         k = n;
  591.                                         d = next byte;
  592.  
  593.                                         Use d (256 * o + k) times.
  594.                                 }
  595.                                 else {
  596.                                         d = next byte;
  597.                                         Use d (n) times.
  598.                                 }
  599.  
  600.         x != escape byte        Use x literally.
  601.  
  602. Compressed data, delta compressed:
  603.  
  604. For each byte x in the data section:
  605.  
  606.         x = escape byte         Read one more byte, n.  (n is unsigned).
  607.  
  608.                                 If n >= 3, use the next byte n times.
  609.                                 If n = 1, do the same as for n = 1 in
  610.                                 stand-alone compression (above).
  611.                                 If n = 2, then set n = next byte.
  612.                                         If n = 0, end of picture.
  613.                                         If n >= 2, take n bytes from base
  614.                                         picture.
  615.                                         If n = 1, do the same as for n = 1
  616.                                         in stand-alone compression (above),
  617.                                         but take (256 * o + k) bytes from 
  618.                                         base picture.
  619.  
  620.         x != escape byte        Use x literally.
  621.  
  622.  
  623. <IFF Format>    *.IFF
  624.  
  625. 4 bytes         "FORM" (FORM chunk ID)
  626. 1 long          length of file that follows
  627. 4 bytes         "ILBM" (InterLeaved BitMap file ID)
  628.  
  629. 4 bytes         "BMHD" (BitMap HeaDer chunk ID)
  630. 1 long          length of chunk [20]
  631. 20 bytes        1 word = image width in pixels
  632.                 1 word = image height in lines
  633.                 1 word = image x-offset [usually 0]
  634.                 1 word = image y-offset [usually 0]
  635.                 1 byte = # bitplanes
  636.                 1 byte = mask (0=no, 1=impl., 2=transparent, 3=lasso)
  637.                 1 byte = compressed [1] or uncompressed [0]
  638.                 1 byte = unused [0]
  639.                 1 word = transparent color (for mask=2)
  640.                 1 byte = x-aspect [5=640x200, 10=320x200/640x400, 20=320x400]
  641.                 1 byte = y-aspect [11]
  642.                 1 word = page width (usually the same as image width)
  643.                 1 word = page height (usually the same as image height)
  644.  
  645. 4 bytes         "CMAP" (ColorMAP chunk ID)
  646. 1 long          length of chunk [3*n where n is the # colors]
  647. 3n bytes        3 bytes per RGB color.  Each color value is a byte
  648.                 and the actual color value is left-justified in the
  649.                 byte such that the most significant bit of the value
  650.                 is the MSB of the byte.  (ie. a color value of 15 ($0F)
  651.                 is stored as $F0)  The bytes are stored in R,G,B order.
  652.  
  653. 4 bytes         "CRNG" (Color RaNGe chunk ID)
  654. 1 long          length of chunk [8]
  655. 8 bytes         1 word = reserved [0]
  656.                 1 word = animation speed (16384 = 60 steps per second)
  657.                 1 word = active [1] or inactive [0]
  658.                 1 byte = left/lower color animation limit
  659.                 1 byte = right/upper color animation limit
  660.  
  661. 4 bytes         "CAMG" (Commodore AMiGa viewport mode chunk ID)
  662. 1 long          length of chunk [4]
  663. 1 long          viewport mode bits (bit 11 = HAM, bit 3 = interlaced)
  664.  
  665. 4 bytes         "BODY" (BODY chunk ID)
  666. 1 long          length of chunk [# bytes of image data that follow]
  667. ? bytes         actual image data
  668.  
  669. NOTES: Some of these chunks may not be present in every IFF file, and may
  670. not be in this order.  You should always look for the ID bytes to find a
  671. certain chunk.  All chunk IDs are followed by a long value that tells the
  672. size of the chunk.  This is the number of bytes that FOLLOW the 4 ID bytes
  673. and size longword.  The exception to this is the FORM chunk.  The size
  674. longword that follows the FORM ID is the size of the remainder of the file.
  675. The FORM chunk must always be the first chunk in an IFF file.
  676.  
  677. The R,G,B ranges of AMIGA and ST are different (AMIGA 0...15, ST 0...7),
  678. as is the maximum number of bitplanes (AMIGA: 5, ST: 4).
  679.  
  680. Format of body data
  681.  
  682. An expanded picture is simply a bitmap.  The packing method is PackBits
  683. (see below), and is identical to MacPaint and DEGAS Elite compressed.
  684.  
  685. The (decompressed) body data appears in the following order:
  686.  
  687.         line 1 plane 0 ... line 1 plane 1 ... ... line 1 plane m
  688.         [line 1 mask (if appropriate)]
  689.         line 2 plane 0 ... line 2 plane 1 ... ... line 2 plane m
  690.         [line 2 mask (if appropriate)]
  691.         ...
  692.         line x plane 0 ... line x plane 1 ... ... line x plane m
  693.         [line x mask (if appropriate)]
  694.  
  695. The FORM chunk identifies the type of data:
  696.  
  697.         "ILBM" = interleaved bit map
  698.         "8SVX" = 8-bit sample voice
  699.         "SMUS" = simple music score
  700.         "FTXT" = formatted text (Amiga)
  701.  
  702.  
  703. <MacPaint>      *.MAC
  704.  
  705. 1 long          version number [0=ignore header, 2=header valid]
  706. 38 * 8 bytes    8x8 brush/fill patterns.  Each byte is a pattern row,
  707.                 and the bytes map the pattern rows top to bottom.  The
  708.                 patterns are stored in the order they appear at the bottom
  709.                 of the MacPaint screen top to bottom, left to right.
  710. 204 bytes       unused
  711. -------------
  712. 512 bytes       total for header
  713.  
  714. < 51200 bytes   compressed bitmap data
  715. -------------
  716. < 51712 bytes   total
  717.  
  718. NOTE:  The version number is actually a flag to MacPaint to indicate if
  719. the brush/fill patterns are present in the file.  If the version is 0,
  720. the default patterns are used.  Therefore you can simply save a MacPaint
  721. file by writing a blank header (512 $00 bytes), followed by the packed
  722. image data.
  723.  
  724. Bitmap compression:
  725.  
  726.    The bitmap data is for a 576 pixel by 720 pixel monochrome image.
  727. The packing method is PackBits (see below).  There are 72 bytes per
  728. scan line.  Each bit represents one pixel; 0 = white, 1 = black.
  729.  
  730.  
  731. <PackBits Compression Algorithm>
  732.  
  733. The following packing algorithm originated on the Mac, was adopted by
  734. Electronic Arts/Commodore for use in the IFF standard, and then by Tom
  735. Hudson for use in DEGAS Elite.  The algorithm is currently used in
  736. MacPaint, IFF, and DEGAS Elite compressed file formats.  Each scan line
  737. is packed separately, and packing never extends beyond a scan line.
  738.  
  739. For a given control byte 'n':
  740.     0 <= n <= 127   : use the next n + 1 bytes literally (no repetition).
  741.  -127 <= n <= -1    : use the next byte -n + 1 times.
  742.          n = -128   : no operation, not used.
  743.  
  744. -------------------------------------------------------------------------
  745.  
  746. * Roland Waldi contributed extensive information on the following formats:
  747.  
  748.         GEM, IMG, Doodle, STAD, Imagic Film/Picture, Art Director, IFF
  749.  
  750. ** John Brochu, ST picture formats guru, provided sage advice and many
  751.    corrections to the following formats:
  752.  
  753.         NeoChrome, DEGAS Elite Compressed, Spectrum 512 Compressed,
  754.         GEM Bit Image, IFF, MacPaint
  755.  
  756. Version of Wed Dec 19 11:20:55 EST 1990
  757. Cosmetic changes Tue Jan 29 00:17:51 EST 1991
  758.  
  759.  
  760.  
  761.